package service;

import java.text.SimpleDateFormat;
import java.util.Date;

import dao.ContactDao;
import entity.Contact;
import entity.User;

public class NewContactservice {

	private ContactDao dao=new ContactDao();
	
	public void save(User user,String name,String companyname,String mobile,String tel,String e_mail,String address,String website,String weibo,String content){
		
		String contactId=getContactId();
		
		Contact con=new Contact();
		con.setId(contactId);
		con.setC_name(name);
		con.setCompany_name(companyname);
		con.setMobile(mobile);
		con.setTel(tel);
		con.setE_mail(e_mail);
		con.setAddress(address);
		con.setWebsite(website);
		con.setWeibo(weibo);
		con.setContent(content);
		
		dao.save(con);
	}

	private String getContactId() {
		Date date=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
		String id=sdf.format(date);
		return id;
	}
}
